|
|
|
|
|
|
|
the data table you are updating and name of the key field are pulled from properties already set by the user. For all your ODBC datasets, you are assuming that the first field in the list is the primary key field. |
|
|
|
|
| |
|
|
|
|
Assuming that the primary key field is always the first physical field in the dataset can be a limitation when you're dealing with secondary tables and other non-normalized datasets. For now, however, this assumption handles most of your data-entry needs. As you develop more skill with ODBC routines, you can modify these routines or add others that give you more flexibility in sharing data over ODBC connections. |
|
|
|
|
|
|
|
|
|
|
The routine in Listing 19.20 builds a standard DELETE query using the parameters you supplied to it and then executes the SQL DELETE, returning any error messages that might result. |
|
|
|
|
|
|
|
|
Now you build the AddRow method. This routine builds a standard APPEND query using the INSERT INTO syntax. Create the new function and add the code in Listing 19.21. |
|
|
|
|
|
|
|
|
Listing 19.21. Coding the AddRow method. |
|
|
|
|
|
|
|
|
Public Sub AddRow(frmTemp As Object)
'
' add a new row of data to the table
'
Dim intResult As Integer
Dim strSQL As String
Dim intLoop As Integer
'
strSQL = "INSERT INTO " & strTable & " VALUES("
'
For intLoop = 1 To NumCols
strSQL = strSQL & "'" & frmTemp.sqlfield(intLoop - 1) & "'"
If intLoop <> NumCols Then
strSQL = strSQL & ","
End If
Next
strSQL = strSQL & ")"
'
' now make the call
intResult = SQLExecDirect(hStmt, strSQL, Len(strSQL))
If intResult <> sqlSuccess Then
sqlErrorMsg "Unable to add row"
intResult = SQLFreeStmt(hStmt, sqlClose)
End If
'
End Sub |
|
|
|
|
|